
var url = 'http://47.108.197.28:3000/top/playlist/highquality'
$(function () {
    $ajax({
        url,
        success: res => {
            var play = res.playlists;
           
                play.slice(0,9).forEach(item => {
                    var { name, coverImgUrl, playCount } = item;
                   var count =  Count(playCount)
                    // console.log(count)
                    var template = `
                   <div class="content">
                        <div><img src="${coverImgUrl}" alt=""></div>
                        <div class = "play"><i class="iconfont">&#xea6d;</i>${count}</div>
                        <div>${name}</div>
                    </div>
                   `
                   $(".container").append(template)
                });
            
        }
    })
    function Count(playCount){
        if(playCount>10000){
            playCount = Math.ceil(playCount/10000)+'万'
        }
        else if(playCount>100000000){
            playCount = Math.floor(playCount/100000000)+'亿'
        }
        return playCount;
    }
})